﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Xsl;
using System.Xml.XPath;

namespace CSharpLearning
{
    public sealed class Xslt
    {
        public static Xslt GetInstance { get { return XsltInstance.Instance; } }
        private class XsltInstance
        {
            internal static readonly Xslt Instance = new Xslt();
            private XsltInstance() { }
        }

        private Xslt()
        {

        }

        public void XsltCreate(string XmlDoc, string XsltDoc, string ResultFile)
        {
            try
            {
                XPathDocument xpath = new XPathDocument(XmlDoc);
                XslCompiledTransform xsltrans = new XslCompiledTransform();
                xsltrans.Load(XsltDoc);
                XmlTextWriter xmlwritter = new XmlTextWriter(ResultFile, null);
                xsltrans.Transform(xpath, null, xmlwritter);
                xmlwritter.Close();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public void DisplayMsg()
        {
            Console.WriteLine("Xslt instance object");
        }

    }   
}
